{% extends 'generic/object.html' %}
{% load helpers %}
{% load plugins %}
{% load i18n %}
{% load mptt %}

{% block breadcrumbs %}
  {{ block.super }}
  <li class="breadcrumb-item">
    <a href="{% url 'dcim:module_list' %}?module_type_id={{ object.module_type.pk }}">{{ object.module_type }}</a>
  </li>
{% endblock %}

{% block extra_controls %}
  {% if perms.dcim.change_module %}
    <div class="dropdown">
      <button id="add-components" type="button" class="btn btn-primary dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
        <i class="mdi mdi-plus-thick" aria-hidden="true"></i> {% trans "Add Components" %}
      </button>
      <ul class="dropdown-menu" aria-labeled-by="add-components">
        {% if perms.dcim.add_consoleport %}
          <li><a class="dropdown-item" href="{% url 'dcim:consoleport_add' %}?device={{ object.device.pk }}&module={{ object.pk }}&return_url={{ object.get_absolute_url }}">{% trans "Console Ports" %}</a></li>
        {% endif %}
        {% if perms.dcim.add_consoleserverport %}
          <li><a class="dropdown-item" href="{% url 'dcim:consoleserverport_add' %}?device={{ object.device.pk }}&module={{ object.pk }}&return_url={{ object.get_absolute_url }}">{% trans "Console Server Ports" %}</a></li>
        {% endif %}
        {% if perms.dcim.add_powerport %}
          <li><a class="dropdown-item" href="{% url 'dcim:powerport_add' %}?device={{ object.device.pk }}&module={{ object.pk }}&return_url={{ object.get_absolute_url }}">{% trans "Power Ports" %}</a></li>
        {% endif %}
        {% if perms.dcim.add_poweroutlet %}
          <li><a class="dropdown-item" href="{% url 'dcim:poweroutlet_add' %}?device={{ object.device.pk }}&module={{ object.pk }}&return_url={{ object.get_absolute_url }}">{% trans "Power Outlets" %}</a></li>
        {% endif %}
        {% if perms.dcim.add_interface %}
          <li><a class="dropdown-item" href="{% url 'dcim:interface_add' %}?device={{ object.device.pk }}&module={{ object.pk }}&return_url={{ object.get_absolute_url }}">{% trans "Interfaces" %}</a></li>
        {% endif %}
        {% if perms.dcim.add_frontport %}
          <li><a class="dropdown-item" href="{% url 'dcim:frontport_add' %}?device={{ object.device.pk }}&module={{ object.pk }}&return_url={{ object.get_absolute_url }}">{% trans "Front Ports" %}</a></li>
        {% endif %}
        {% if perms.dcim.add_rearport %}
          <li><a class="dropdown-item" href="{% url 'dcim:rearport_add' %}?device={{ object.device.pk }}&module={{ object.pk }}&return_url={{ object.get_absolute_url }}">{% trans "Rear Ports" %}</a></li>
        {% endif %}
        {% if perms.dcim.add_modulebay %}
          <li><a class="dropdown-item" href="{% url 'dcim:modulebay_add' %}?device={{ object.device.pk }}&module={{ object.pk }}&return_url={{ object.get_absolute_url }}">{% trans "Module Bays" %}</a></li>
        {% endif %}
      </ul>
    </div>
  {% endif %}
{% endblock %}

{% block content %}
<div class="row">
	<div class="col col-12 col-md-6">
    <div class="card">
      <h2 class="card-header">{% trans "Module" %}</h2>
      <table class="table table-hover attr-table">
        <tr>
          <th scope="row">{% trans "Device" %}</th>
          <td>{{ object.device|linkify }}</td>
        </tr>
        <tr>
          <th scope="row">{% trans "Device Type" %}</th>
          <td>{{ object.device.device_type|linkify }}</td>
        </tr>
        <tr>
          <th scope="row">{% trans "Module Bay" %}</th>
          <td>{% nested_tree object.module_bay %}</td>
        </tr>
        <tr>
          <th scope="row">{% trans "Status" %}</th>
          <td>{% badge object.get_status_display bg_color=object.get_status_color %}</td>
        </tr>
        <tr>
          <th scope="row">{% trans "Description" %}</th>
          <td>{{ object.description|placeholder }}</td>
        </tr>
        <tr>
          <th scope="row">{% trans "Serial Number" %}</th>
          <td class="font-monospace">{{ object.serial|placeholder }}</td>
        </tr>
        <tr>
          <th scope="row">{% trans "Asset Tag" %}</th>
          <td class="font-monospace">{{ object.asset_tag|placeholder }}</td>
        </tr>
      </table>
    </div>
    {% include 'inc/panels/tags.html' %}
    {% include 'inc/panels/comments.html' %}
    {% plugin_left_page object %}
  </div>
  <div class="col col-12 col-md-6">
    <div class="card">
      <h2 class="card-header">{% trans "Module Type" %}</h2>
      <table class="table table-hover attr-table">
        <tr>
          <th scope="row">{% trans "Manufacturer" %}</th>
          <td>{{ object.module_type.manufacturer|linkify }}</td>
        </tr>
        <tr>
          <th scope="row">{% trans "Model" %}</th>
          <td>{{ object.module_type|linkify }}</td>
        </tr>
        {% for k, v in object.module_type.attributes.items %}
          <tr>
            <th scope="row">{{ k }}</th>
            <td>{{ v|placeholder }}</td>
          </tr>
        {% endfor %}
      </table>
    </div>
    {% include 'inc/panels/related_objects.html' %}
    {% include 'inc/panels/custom_fields.html' %}
    {% plugin_right_page object %}
	</div>
</div>
<div class="row">
  <div class="col col-md-12">
    {% plugin_full_width_page object %}
  </div>
</div>
{% endblock %}
